Repository navigation
ios27/a64e: translate libcorecrypto (the S9's hottest A64E traps) and reseal its FIPS seal; a64e census + log/verify/restore - #384
Merged
Conversation
…and log/verify/restore for a64e-rewrite The S9's hottest A64E traps on 24B156 (~100k RETAB traps per 10 s while iconservicesagent re-renders icons after a dark-mode switch, thousands at idle) are all in /usr/lib/system/libcorecrypto.dylib, which the cache pipeline skipped because its FIPS self-test MACs its own __text. That MAC is HMAC-SHA256 with an all-zero key over __TEXT,__text, stored in __TEXT,__fips_hmacs (apple/corecrypto fipspost_get_hmac.c), so it can be recomputed for the rewritten code. - a64e/fips-seal.py check|reseal|restore: recompute the seal only where it was true in the reference (stock) cache and the stored value is still the reference one; logged, restorable. Pure Python. - a64e/fips-seal-test.py (CI): made-up Mach-O files; sealed, broken, reseal, restore, refusals. - a64e-rewrite.py: cache --log (ADDR OLD NEW), verify/restore from the log, and census: per image the words the rewrite would still change, nothing skipped; exit 1 unless allowed. - cache-pipeline.sh: steps 1/2/4 skip only the unloaded libcorecrypto_noasm/_trace; 5b reseal + check; 9 census. - docs/ios27/CORECRYPTO.md; INSTALL-S9.md and SPEED.md updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The S9's hottest arm64e traps on iOS 27.2.1 (24B156) are all in
/usr/lib/system/libcorecrypto.dylib. The cache pipeline skipped that library (--skip libcorecrypto) because corecrypto's FIPS self-test MACs its own code, so its 3,538 pointer-auth words (1,500RETA*, 67BRA*, 1,312BLRA*, 659PAC*/AUT*register forms) went through the kernel's emulation on every call.Evidence (phone 1,
o272, root v9, console logcon-xnu-boot-p8-metal-passes.log):STARLTE A64E hotsites0x1d919fc5cand0x1d919fbe0(RETABd65f0fff) took 106,512 and 104,880 traps in one 10 s interval at 16:18:50 whileiconservicesagentre-rendered icons after a dark-mode switch, and 2,000-15,000 per 10 s at idle. More sites:d63f091f(BLRAAZ x8),d73f0a11(BLRAA x16, x17),d61f08bf(BRAAZ x5).slide 0x63a8000shows the same site as0x1da0a3c5c, the one withslide 0x54a4000as0x1d919fc5c; both are0x1d3cfbc5cunslid.libcorecrypto.dylib__TEXT,__text. The hottest pair is the return ofccder_blob_decode_rangeand of the local function after it, thenccder_sizeofand some local functions. The hot LSE site0x1d919e77cis the library's onlySWP(b8298100, unslid0x1d3cfa77c).The fix
corecrypto's integrity check (
fipspost_get_hmac.c) computes HMAC-SHA256 with a key of 32 zero bytes over the image's__TEXT,__textand compares it with__TEXT,__fips_hmacs. On the 24B156 cache the stored value is exactly that HMAC, so it can be recomputed for the rewritten code.tools/ios27/a64e/fips-seal.py check|reseal|restore. It reseals only an image whose seal was true in the reference (stock) cache and whose stored value is still the reference one. Each reseal is logged and can be restored. Pure Python.tools/ios27/a64e/fips-seal-test.py, also run in CI: made-up Mach-O files covering sealed, broken after rewrite, dry run, reseal, a change after the reseal, refusal of a moved seal, restore, and a seal that was already false.a64e-rewrite.py:cache --logwritesADDR OLD NEWfor every changed word;verifyandrestorework from that log (the same round trip aslse-rewrite.py).censuslists, per image, the words the rewrite would still change, with nothing skipped, and exits 1 unless the image is allowed. On the v9 cache it flags exactly the three corecrypto images out of 4,759, so it would have caught this.cache-pipeline.sh:libcorecrypto_noasm/_trace(their seals are false in the stock cache already);PREreference;TEXTDATA_SKIPhere (the pipeline sets it): two SHA-256 K words (78a5636f) in corecrypto's__textdecode asLDUMAXAH.docs/ios27/CORECRYPTO.md(new),INSTALL-S9.md,SPEED.md.Nothing Apple-derived is in the repo, only tools and docs.
Tests
fips-seal-test.py: all ok.lse/test/run.sh: 5/5 STRESS OK. The 28 diff lines are all the documented Rs==Rn cases.a64e-rewrite.py censuson the v9 cache flags the 3 corecrypto images, and only the 2 allowed variants after the step.verifyreports 3538 ok;SWPgot a thunk,lse verifyreports 1 ok, and the 2 table words were left alone;checkreports sealed;.21and 4 of.19differ from v9.textdata-guard.py scan --pacflagged 6 of the changed words by rule D. I reviewed all 6 and they are ordinary code.cache-pipeline.shrun was not repeated from a stock cache. The changed steps were run one by one on the v9 root.package.json/npm run preflight. I ran the CI steps that apply locally: py_compile, provenance-check, docs-check and fips-seal-test.🤖 Generated with Claude Code